#ifndef MARKET_DATA_H
#define MARKET_DATA_H

#include <atomic>
#include <cstdint>
#include <semaphore.h>

struct Tick {
  uint64_t timestamp;
  char symbol[8];
  double price;
  uint64_t volume;
} __attribute__((aligned(64)));

struct ShmHeader {
  std::atomic<size_t> head;   // 预分配头指针（生产者竞争）
  std::atomic<size_t> commit; // 已提交头指针（消费者可见）
  std::atomic<size_t> tail;   // 消费指针
  sem_t data_ready;
  sem_t space_available;
  size_t capacity;
  size_t item_size;
};

constexpr const char *SHM_NAME = "/tick_ring_buffer";
constexpr size_t BUFFER_CAPACITY = 1024;

#endif